set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")

if(SUBSYSTEM_NAME STREQUAL "iOS")	
	SET (SDKVER "5.0")
	SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
	SET (SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk")
	SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
	SET (CMAKE_OSX_ARCHITECTURES "armv7;i386") #"$(ARCHS_STANDARD_32_BIT)") #"$(ARCHS_UNIVERSAL_IPHONE_OS)")
	SET (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
	#Other 'CMAKE_OSX_ARCHITECTURES' iPhone/IOS option examples
	#SET (CMAKE_OSX_ARCHITECTURES "armv7")
	#SET (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)		
else()
	if (${SUBSYSTEM_NAME})
		EXEC_PROGRAM(xcodebuild ARGS -version OUTPUT_VARIABLE XCODE_VERSION)
		STRING(REGEX MATCH "[0-9][.][0-9]" XCODE_VERSION ${XCODE_VERSION})
		if (${XCODE_VERSION} GREATER 4.2)
		    set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SUBSYSTEM_NAME}.sdk)
		else()
		    set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${SUBSYSTEM_NAME}.sdk)
		endif()
		set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_OSX_SYSROOT}/usr)
	endif()
	SET(CMAKE_OSX_DEPLOYMENT_TARGET ${SUBSYSTEM_NAME} CACHE STRING "Deployment target for OSX" FORCE)
	MESSAGE(STATUS "CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT}")
	MESSAGE(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
	find_package(Threads REQUIRED)
	set(CMAKE_OSX_ARCHITECTURES "i386;x86_64")
	set(COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC")
endif()